import 'package:nyh_motorcade_app/entity/driver_info_entity.dart';

driverInfoEntityFromJson(DriverInfoEntity data, Map<String, dynamic> json) {
	if (json['page'] != null) {
		data.page = json['page'] is String
				? int.tryParse(json['page'])
				: json['page'].toInt();
	}
	if (json['pageSize'] != null) {
		data.pageSize = json['pageSize'] is String
				? int.tryParse(json['pageSize'])
				: json['pageSize'].toInt();
	}
	if (json['total'] != null) {
		data.total = json['total'] is String
				? int.tryParse(json['total'])
				: json['total'].toInt();
	}
	if (json['totalPage'] != null) {
		data.totalPage = json['totalPage'] is String
				? int.tryParse(json['totalPage'])
				: json['totalPage'].toInt();
	}
	if (json['item'] != null) {
		data.item = (json['item'] as List).map((v) => DriverInfoItem().fromJson(v)).toList();
	}
	return data;
}

Map<String, dynamic> driverInfoEntityToJson(DriverInfoEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['page'] = entity.page;
	data['pageSize'] = entity.pageSize;
	data['total'] = entity.total;
	data['totalPage'] = entity.totalPage;
	data['item'] =  entity.item?.map((v) => v.toJson())?.toList();
	return data;
}

driverInfoItemFromJson(DriverInfoItem data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['phone'] != null) {
		data.phone = json['phone'].toString();
	}
	if (json['motorcadeId'] != null) {
		data.motorcadeId = json['motorcadeId'].toString();
	}
	if (json['vehicleIds'] != null) {
		data.vehicleIds = (json['vehicleIds'] as List).map((v) => v is String
				? int.tryParse(v)
				: v.toInt()).toList().cast<int>();
	}
	if (json['motorcadeIds'] != null) {
		data.motorcadeIds = (json['motorcadeIds'] as List).map((v) => v is String
				? int.tryParse(v)
				: v.toInt()).toList().cast<int>();
	}
	if (json['motorcadeName'] != null) {
		data.motorcadeName = json['motorcadeName'].toString();
	}
	if (json['status'] != null) {
		data.status = json['status'] is String
				? int.tryParse(json['status'])
				: json['status'].toInt();
	}
	if (json['remake'] != null) {
		data.remake = json['remake'].toString();
	}
	if (json['vehicleNumbers'] != null) {
		data.vehicleNumbers = json['vehicleNumbers'].toString();
	}
	if (json['belongingType'] != null) {
		data.belongingType = json['belongingType'].toString();
	}
	if (json['belongingTypeName'] != null) {
		data.belongingTypeName = json['belongingTypeName'].toString();
	}
	if (json['ifCardModel'] != null) {
		data.ifCardModel = json['ifCardModel'] is String
				? int.tryParse(json['ifCardModel'])
				: json['ifCardModel'].toInt();
	}
	if (json['subCompanyList'] != null) {
		data.subCompanyList = (json['subCompanyList'] as List).map((v) => v.toString()).toList().cast<String>();
	}
	if (json['refuelQuota'] != null) {
		data.refuelQuota = json['refuelQuota'] is String
				? double.tryParse(json['refuelQuota'])
				: json['refuelQuota'].toDouble();
	}
	if (json['remainQuota'] != null) {
		data.remainQuota = json['remainQuota'] is String
				? double.tryParse(json['remainQuota'])
				: json['remainQuota'].toDouble();
	}
	if (json['circle'] != null) {
		data.circle = json['circle'].toString();
	}
	if (json['unit'] != null) {
		data.unit = json['unit'].toString();
	}
	if (json['bindingState'] != null) {
		data.bindingState = json['bindingState'];
	}
	if (json['isSelect'] != null) {
		data.isSelect = json['isSelect'];
	}
	return data;
}

Map<String, dynamic> driverInfoItemToJson(DriverInfoItem entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['name'] = entity.name;
	data['phone'] = entity.phone;
	data['motorcadeId'] = entity.motorcadeId;
	data['vehicleIds'] = entity.vehicleIds;
	data['motorcadeIds'] = entity.motorcadeIds;
	data['motorcadeName'] = entity.motorcadeName;
	data['status'] = entity.status;
	data['remake'] = entity.remake;
	data['vehicleNumbers'] = entity.vehicleNumbers;
	data['belongingType'] = entity.belongingType;
	data['belongingTypeName'] = entity.belongingTypeName;
	data['ifCardModel'] = entity.ifCardModel;
	data['subCompanyList'] = entity.subCompanyList;
	data['refuelQuota'] = entity.refuelQuota;
	data['remainQuota'] = entity.remainQuota;
	data['circle'] = entity.circle;
	data['unit'] = entity.unit;
	data['bindingState'] = entity.bindingState;
	data['isSelect'] = entity.isSelect;
	return data;
}